package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.Overall;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.IOverallService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 统筹区
 *
 * @author hwh
 */
@Api(value = "/system/overall", tags = {"统筹区"})
@RestController
@RequestMapping("/system/overall")
public class OverallController extends BaseController {

    @Resource
    private IOverallService overallService;

    /**
     * 新增统筹区
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "Overall", name = "overall", value = "", required = true)
    })
    @ApiOperation(value = "新增统筹区", notes = "新增统筹区", httpMethod = "POST")
    @PostMapping("/add")
    @Log(title = "统筹区管理", businessType = BusinessType.INSERT)
    public AjaxResult add(@Validated @RequestBody Overall overall) {
        return toAjax(overallService.addOverall(overall));
    }

    /**
     * 编辑统筹区
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "Overall", name = "overall", value = "", required = true)
    })
    @ApiOperation(value = "编辑统筹区", notes = "编辑统筹区", httpMethod = "POST")
    @Log(title = "统筹区管理", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult update(@Validated @RequestBody Overall overall) {
        return toAjax(overallService.updateOverall(overall));
    }


    /**
     * 获取统筹区列表
     */
    @ApiOperation(value = "获取统筹区列表", notes = "获取统筹区列表", httpMethod = "GET")
    @GetMapping("/list")
    public AjaxResult list(Overall overall) {
        return success(overallService.selectOverallList(overall));
    }

    /**
     * 删除统筹区
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "long", name = "overallId", value = "", required = true)
    })
    @ApiOperation(value = "删除统筹区", notes = "删除统筹区", httpMethod = "DELETE")
    @Log(title = "统筹区管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{overallId}")
    public AjaxResult remove(@PathVariable("overallId") Integer overallId) {
        return toAjax(overallService.deleteOverall(overallId));
    }
}
